<template>
  <view class="car-detail">
    <!-- 牌照 -->
    <view class="local-car-license" v-if="item.carLicense == 1">
      <LicenseText>{{ carLicenseDesc }}</LicenseText>
    </view>
    <view class="car-detail-t">
      <view class="car-detail-img">
        <image :src="carPicShow" mode="widthFix" />
      </view>
      <view class="car-detail-t-r">
        <!-- 汽车品牌 + 车型 -->
        <view>{{ carInfo.autoBrand + carInfo.name }}</view>
        <view>{{ carInfo.carName }}</view>
        <view class="car-detail-t-types">
          <view>
            <!-- 几座 -->
            <text v-if="carInfo.seatNum">{{ carInfo.seatNum + "座 | " }} </text>
            <!-- 燃油类型 -->
            <text v-if="carInfo.fuelTypeName">{{
              carInfo.fuelTypeName + " | "
            }}</text>
            <!-- 变速箱类型 -->
            <text v-if="carInfo.transmissionName">{{
              carInfo.transmissionName + '档 | '
            }}</text>
            <!-- 类型 -->
            <text v-if="carInfo.typeName">{{ carInfo.typeName }}</text>
          </view>
        </view>
      </view>
    </view>
    <u-line color="#ccc" margin="10rpx 0" />
    <!-- 供应商信息 -->
    <view class="supplier-info">
      <view class="supplier-info-item">供应商名称：{{ supplierInfo.name }}</view>
      <view class="supplier-info-item">供应商标签：
        <template v-if="supplierInfo.tagList && supplierInfo.tagList.length > 0">
          <view class="tag" v-for="(tag,index) in supplierInfo.tagList" :key="index">
            {{ tag }}
          </view>
        </template>
        <template v-else>-</template>
      </view>
    </view>
    <u-line color="#ccc" margin="10rpx 0" />
    <!-- 标签 -->
    <view class="car-detail-c">
      <view v-for="(items, indexs) in carTags" :key="indexs">{{ items }}</view>
    </view>
    <view class="car-detail-b">
      <view class="car-detail-b-l">
        <view>单价：¥</view>
        <view>{{ item.unitPrice }}</view>
        <view>/天</view>
      </view>
      <view class="car-detail-b-r">
        <view>总价：¥</view>
        <view>{{ item.totalFee }}</view>
      </view>
      <!-- 预订 -->
      <view class="car-detail-b-r book" @click="onBookBtnClick">订</view>
    </view>
    <view class="item-line"></view>
  </view>
</template>
<script>
import LicenseText from './licenseText.vue';
export default {
  name: "rentCarPriceItem",
  props: {
    item: {
      type: Object,
      default: () => {
        return {};
      },
    },
    basicParam: {
      type: Object,
      default: () => {
        return {};
      },
    }
  },
  components: {
    LicenseText
  },
  computed: {
    // 车辆信息
    carInfo() {
      return this.item.carInfo;
    },
    // 门店信息
    storeInfo() {
      return this.item.storeInfo;
    },
    // 供应商信息
    supplierInfo() {
      return {
        ...this.item.supplierInfo,
      };
    },
    // 车辆图片
    carPicShow() {
      let carInfo = this.carInfo;
      let pics = carInfo.pics;
      if (pics) {
        let picsArr = pics.split(",");
        let img = picsArr[0];
        return img;
      } else {
        return "../static/images/nocarimg.png";
      }
    },
    // 车辆标签
    carTags() {
      const tagList = this.item.tagList || []
      return [
        ...tagList,
        this.item.pickUpCarTypeName,
      ]
    },
    // 车牌类型
    carLicenseDesc() {
      const cityName = this.basicParam.cityName
      if (cityName == '北京') {
        return '京牌'
      }
      if (cityName == '上海') {
        return '沪牌'
      }
      return '本地'
    }
  },
  methods: {
    onBookBtnClick() {
      this.$emit('bookModel')
    }
  }
};
</script>
<style lang="less" scoped>
.car-detail {
  position: relative;
  margin: 32rpx;
  .local-car-license {
    position: absolute;
    left: -16rpx;
    top: -6rpx;
    z-index: 2;
    transform: rotate(324deg);
  }
  .item-line {
    position: absolute;
    width: 100%;
    height: 2rpx;
    background: #ebedf0;
    transform: scaleY(0.5);
  }
  .car-detail-t {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    .car-detail-img {
      width: 200rpx;
      height: 150rpx;
      border-radius: 4rpx;
      background: #f6f7fb;
      overflow: hidden;
      image {
        width: 100%;
      }
    }
    .car-detail-t-r {
      display: flex;
      flex-direction: column;
      justify-content: flex-start;
      align-items: flex-start;
      margin-left: 16rpx;
      width: 330rpx;
      white-space: initial;
      view:nth-child(1) {
        color: #212329;
        font-size: 28rpx;
        font-weight: 700;
        white-space: break-spaces;
      }
      .car-detail-t-types {
        margin-top: 4rpx;
        white-space: break-spaces;
        view {
          display: inline-block;
          color: #909399;
          font-size: 24rpx;
          font-weight: 500;
        }
      }
    }
  }
  .car-detail-c {
    margin: 16rpx 0 3rpx;
    white-space: normal;
    word-break: break-all;
    view {
      display: inline-block;
      font-size: 22rpx;
      margin-right: 12rpx;
      margin-bottom: 16rpx;
      padding: 4rpx 12rpx;
      border-radius: 4rpx;
      border: 1rpx solid #2f86f6;
      color: #2f86f6;
    }
    view:nth-child(1) {
      background-image: linear-gradient(to right, #1e72ff 0%, #42a1ff 100%);
      color: #ffffff;
    }
  }
  .car-detail-b {
    width: 100%;
    padding-bottom: 20rpx;
    border-radius: 4rpx;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    .car-detail-b-l {
      display: flex;
      justify-content: flex-start;
      align-items: center;
      color: #909399;
      font-size: 24rpx;
      margin-right: 16rpx;
    }
    .car-detail-b-r {
      color: #fc5042;
      display: flex;
      justify-content: flex-end;
      align-items: baseline;
      view:nth-child(1) {
        font-size: 24rpx;
        font-weight: 700;
      }
      view:nth-child(2) {
        font-weight: 700;
        font-size: 32rpx;
        line-height: 1;
        padding: 0;
      }
      view:nth-child(3) {
        font-size: 24rpx;
        color: #909399;
      }
    }
    .book {
      padding: 12rpx 18rpx;
      border-radius: 4rpx;
      margin-left: 12rpx;
      color: #fff;
      background: linear-gradient(134deg, #fb881d 0%, #fc741e 100%);
    }
  }
}
.supplier-info-item {
  display: block;
}
.tag {
  display: inline-block;
  font-size: 22rpx;
  margin-right: 12rpx;
  margin-bottom: 16rpx;
  padding: 4rpx 12rpx;
  border-radius: 4rpx;
  color: rgb(22, 93, 255);
  background-color: rgb(232, 243, 255);
}
</style>
